<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of OgAccordionelement
 *
 * @author Martin
 */
class OgAccordion implements OgElementInterface {
  private $accEl;             //accordion element
  private $document;    //document header element

  private $accName;           //accordion Name
  private $accHeader;         //accordion Header element

  /**
   *
   * @param <type> $_accordion_name
   * @param <type> $_header
   * @param OgDocument $document
   */
  public function  __construct($_accordion_name, $_header, $document) {
    $this->accName = $_accordion_name;
    $this->accHeader = $_header;
    $this->document = $document;

    $this->initComponents();
  }

  public function getTagName() {
    return $this->accEl->getTagName();
  }

  public function mergeAttributes() {
    return $this->accEl->mergeAttributes();
  }

  public function getInnerHtml() {
    return $this->accEl->getInnerHtml();
  }


  public function addTab($heading) {
    $wrapper = new OgElement('div');
    $wrapper->addComponent(new OgElement($this->accHeader, $heading));

    $content = new OgElement('div', 'tutututtututuututututu');
    $wrapper->addComponent($content);

    $this->accEl->addComponent($wrapper);
  }


  public function toString() {
    $this->accEl->toString();
  }


  protected function initComponents() {
    $this->accEl = new OgElement('div');
    $this->accEl->addAttribute('id', $this->accName);

    $accScript = new OgElement('script');
    $accScript->addAttribute('type', 'text/javascript');

    $accIhStr = '
    $(function(){
				// '.$this->accName.'
				$("#'.$this->accName.'").accordion({ header: "'.$this->accHeader.'" });
			});
    ';

    $accScript->setInnerHtml($accIhStr);

    $this->document->getHeader()->addComponent($accScript);
  }
}
?>